﻿using System;
using System.Collections.Generic;

using System.Text;

namespace Rance.Battle
{
    class 剑士AI_压血 : 剑士AI
    {
        protected override 角色 GetTarget(List<角色> targetList, 队伍状况 队伍状况)
        {
            //优先攻击"准备中"的敌人
            List<角色> tempList = new List<角色>();
            foreach (var item in targetList)
            {
                if (item.是否准备)
                    tempList.Add(item);
            }
            if (tempList.Count == 1)
                return targetList[0];
            else if (tempList.Count > 1)
            {
                var value = 队伍状况.战场.AI乱数表.Random(0, tempList.Count);
                return tempList[value];
            }

            //撇除"步卒"敌人
            tempList.Clear();
            foreach (var item in targetList)
            {
                if (item.兵种.Name == "步卒")
                    continue;

                tempList.Add(item);
            }

            
            if (tempList.Count != 0)
                targetList = tempList;

            targetList.Sort((v1, v2) => v1.行动次序.CompareTo(v2.行动次序));
            targetList.Reverse();

            return targetList[0];
        }

        private static 剑士AI_压血 instance = new 剑士AI_压血();
        public new static 剑士AI_压血 GetInstance()
        {
            return instance;
        }
    }
}
